"""
-实现斐波那契函数(for循环, while循环)
-如果遇到可以转换为`int`类型的参数, 则转换, 否则抛出自定义异常`ParamsTypeError`
"""

def fib(n):
    if n == 1 or n ==2:
        return 1
    else:
        a = 0
        b = 1
        while n > 0:
            t = b
            b = a + b
            a = t
            n = n - 1
        return  a

class paramsTypeError(Exception):
    pass

def func(n):
    try:
        n = int(n)
    except:
        raise  ParamsTypeError("参数非整型")
    print(n)
